home *** CD-ROM | disk | FTP | other *** search
- class CRandom
- {
- var _seed = 0;
- function CRandom(seed)
- {
- if(seed != undefined)
- {
- this.SetSeed(seed);
- }
- }
- function SetSeed(seed)
- {
- this._seed = seed;
- }
- function GetRandom(Void)
- {
- this._seed = (this._seed * 9301 + 49297) % 233280;
- return this._seed / 233280;
- }
- function GetNumInRange(bottom, top)
- {
- return bottom + this.GetRandom() * (top - bottom + 1);
- }
- function GetIntInRange(bottom, top)
- {
- return int(bottom + this.GetRandom() * (top - bottom + 1));
- }
- function GetBoolean(Void)
- {
- return this.GetRandom() < 0.5;
- }
- }
-